///
/// This is currently used for passing --extern flags to rustdoc tests later
/// on.
- pub libraries: HashMap<PackageId, Vec<PathBuf>>,
+ pub libraries: HashMap<PackageId, Vec<(String, PathBuf)>>,
/// An array of all tests created during this compilation.
pub tests: Vec<(String, PathBuf)>,
let mut missing_outputs = false;
if !profile.doc {
for filename in try!(cx.target_filenames(target, profile)).iter() {
- let dst = root.join(filename);
- missing_outputs |= fs::metadata(&dst).is_err();
-
- if profile.test {
- cx.compilation.tests.push((target.name().to_string(), dst));
- } else if target.is_bin() || target.is_example() {
- cx.compilation.binaries.push(dst);
- } else if target.is_lib() {
- let pkgid = pkg.package_id().clone();
- cx.compilation.libraries.entry(pkgid).or_insert(Vec::new())
- .push(dst);
- }
+ missing_outputs |= fs::metadata(root.join(filename)).is_err();
}
}
.display().to_string();
cx.compilation.extra_env.insert("OUT_DIR".to_string(), out_dir);
+ for &(target, profile) in targets {
+ for filename in try!(cx.target_filenames(target, profile)).iter() {
+ let dst = cx.out_dir(pkg, Kind::Target, target).join(filename);
+ if profile.test {
+ cx.compilation.tests.push((target.name().to_string(), dst));
+ } else if target.is_bin() || target.is_example() {
+ cx.compilation.binaries.push(dst);
+ } else if target.is_lib() {
+ let pkgid = pkg.package_id().clone();
+ cx.compilation.libraries.entry(pkgid).or_insert(Vec::new())
+ .push((target.crate_name(), dst));
+ if !target.is_lib() { continue }
+
+ // Include immediate lib deps as well
+ for dep in cx.dep_targets(pkg, target, profile).iter() {
+ let (pkg, target, profile) = *dep;
+ let pkgid = pkg.package_id();
+ if !target.is_lib() { continue }
+ if profile.doc { continue }
+ if cx.compilation.libraries.contains_key(&pkgid) { continue }
+
+ let v = try!(cx.target_filenames(target, profile));
+ let v = v.into_iter().map(|f| {
+ (target.crate_name(),
+ cx.out_dir(pkg, Kind::Target, target).join(f))
+ }).collect::<Vec<_>>();
+ cx.compilation.libraries.insert(pkgid.clone(), v);
+ }
+ }
+ }
+ }
+
if let Some(feats) = cx.resolve.features(pkg.package_id()) {
cx.compilation.features.extend(feats.iter().cloned());
}
let mut p = try!(compile.rustdoc_process(&compile.package));
p.arg("--test").arg(lib)
.arg("--crate-name").arg(&crate_name)
- .arg("-L").arg(&compile.root_output)
- .arg("-L").arg(&compile.deps_output)
+ .arg("-L").arg(&{
+ let mut arg = OsString::from("dependency=");
+ arg.push(&compile.deps_output);
+ arg
+ })
.cwd(compile.package.root());
if test_args.len() > 0 {
p.arg("--cfg").arg(&format!("feature=\"{}\"", feat));
}
- for (pkg, libs) in compile.libraries.iter() {
- for lib in libs.iter() {
- let mut arg = OsString::from(pkg.name());
+ for (_, libs) in compile.libraries.iter() {
+ for &(ref name, ref lib) in libs.iter() {
+ let mut arg = OsString::from(name);
arg.push("=");
arg.push(lib);
p.arg("--extern").arg(&arg);
assert_that(git1.cargo("build").arg("-v").cwd(&dst),
execs().with_status(0));
});
+
+test!(doctest_same_name {
+ let a2 = git_repo("a2", |p| {
+ p.file("Cargo.toml", r#"
+ [project]
+ name = "a"
+ version = "0.5.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "pub fn a2() {}")
+ }).unwrap();
+
+ let a1 = git_repo("a1", |p| {
+ p.file("Cargo.toml", &format!(r#"
+ [project]
+ name = "a"
+ version = "0.5.0"
+ authors = []
+ [dependencies]
+ a = {{ git = '{}' }}
+ "#, a2.url()))
+ .file("src/lib.rs", "extern crate a; pub fn a1() {}")
+ }).unwrap();
+
+ let p = project("foo")
+ .file("Cargo.toml", &format!(r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ a = {{ git = '{}' }}
+ "#, a1.url()))
+ .file("src/lib.rs", r#"
+ #[macro_use]
+ extern crate a;
+ "#);
+
+ assert_that(p.cargo_process("test").arg("-v"),
+ execs().with_status(0));
+});
pub fn foo() -> i32 { 1 }
"#);
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
});